
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<%@ page import="java.util.List" %>
<%@ page import="order.ProcessUtil" %>
<%@ page import="order.OrderService" %>
<%@ page import="order.Order" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: huawei
  Date: 2022/10/22
  Time: 20:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
	<title>我的订单</title>
	<!-- 新 Bootstrap5 核心 CSS 文件 -->
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css">
	<%--icon图标--%>
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css">
	<!--  popper.min.js 用于弹窗、提示、下拉菜单 -->
	<script src="https://cdn.staticfile.org/popper.js/2.9.3/umd/popper.min.js"></script>
	<!-- 最新的 Bootstrap5 核心 JavaScript 文件 -->
	<script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="script/jquery-3.6.0.min.js"></script>
</head>
<body>
<%
	OrderService orderService = new OrderService();

//	String userId = ProcessUtil.getUserIdBySessionId(session);
	List<Order> orderList= orderService.showAllOrder("2187354517");
	if (orderList!=null && orderList.size()!=0){
		session.setAttribute("orderList",orderList);
	}
%>
<nav class="navbar-expand-lg navbar navbar-dark bg-primary">
	<div class="container-fluid ">
		<a class="navbar-brand" href="#">我的订单</a>
		<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
			<span class="navbar-toggler-icon"></span>
		</button>
		<div class="collapse navbar-collapse" id="navbarNavDropdown">
			<ul class="navbar-nav">
				<li class="nav-item">
					<a class="nav-link active" aria-current="page" href="first.jsp">Home</a>
				</li>
			</ul>
		</div>
	</div>
</nav>
<c:if test="${empty sessionScope.orderList}">

	<div class="container" >
		<div class="card position-relative" style="margin: 50px;height: 280px;background: #ffffff url(img/CartBackground.png) no-repeat; background-position: center left;">
			<div class="position-absolute top-50 start-50 translate-middle">
				<h7>
					您还未购买过任何商品哦！赶紧行动吧！您可以：
				</h7><br>
				<a class="btn btn-primary btn-lg" href="first.jsp">购物</a>
			</div>
		</div>
	</div>
</c:if>
<c:if test="${!empty sessionScope.orderList}">
	<div class="container">
		<div class="card">
			<table class="table table-hover text-center">
				<tr>
					<td>订单号</td>
					<td>下单时间</td>
					<td>总价</td>
					<td>状态</td>
					<td>详情</td>
				</tr>
				<c:forEach items="${sessionScope.orderList}" var="order">
					<tr style="vertical-align: middle !important;text-align: center;">
						<td>
								<%--<img style="width: 100px;height: 100px" src="${or}"/>--%>
							<span>${order.id}</span>
						</td>
						<td>
								<%--分割下单时间--%>
							<c:set value="${fn:split(order.create_time,'T')}" var="time"></c:set>
							<c:forEach var="tm" items="${time}">
								${tm}
							</c:forEach>
						</td>
						<td>${order.price}</td>
						<td>0</td>
						<td><a type="submit" class="btn btn-danger" href="orderDetail.jsp">查看</a></td>
					</tr>
				</c:forEach>
			</table>
			<div class="row justify-content-between">


			</div>
		</div>
	</div>
</c:if>
</body>
</html>
